import Vue from 'vue';
import VueRouter from 'vue-router';
import Index from '../views/index.vue';
import LR from '../views/lr.vue';
import NotFond from '../views/notfond.vue';
Vue.use(VueRouter);
const routes = [
  { path: '/', name: 'index', component: Index },
  { path: '/lr', name: 'lr', component: LR },
  { path: '*', name: 'notfond', component: NotFond },
];

const router = new VueRouter({
  routes,
});
router.beforeEach((to, from, next) => {
  let token = localStorage.getItem('token');
  if (to.name != 'lr' && !token) next('/lr');
  next();
});

export default router;
